package com.sam.demo.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import javax.sql.DataSource;


/**
 * 指定数据源的Repository路径
 * 数据源的entityManagerFactory
 * 事务是公共事务
 * @author Administrator
 *
 */
@EnableJpaRepositories(basePackages = "com.sam.demo.repository")
@Configuration
@ConfigurationProperties(prefix = "spring.datasource.primary")
public class PrimaryDataSourceConfig extends JpaDataSourceConfigCommon {

//	@Bean(name = JpaDataSourceConfigCommon.PRIMARY_DATASOURCE_KEY)
//	@Primary
//	public DataSource dataSource() {
//		return super.dataSource(JpaDataSourceConfigCommon.PRIMARY_DATASOURCE_KEY);
//	}

	@Bean(name = JpaDataSourceConfigCommon.PRIMARY_DATASOURCE_KEY)
	@Primary
	public DataSource dataSource() {
		return super.dataSource();
	}


}
